home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / os2tools / bnklysrc / b_ansi.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-01  |  7.4 KB  |  126 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software <no-Inc>                   */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          No-Cost<no-tm> Software.                       */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello  */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*          This module was originally written by Vince Perriello           */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                        BinkleyTerm ANSI mapping                          */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.210.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU SHOULD  IMMEDIATELY CONTACT THE AUTHORS    */
  27. /*    AT THE  ADDRESSES LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO    */
  28. /*    USE   THIS  FILE  WITHOUT  HAVING   ACCEPTED  THE  TERMS  OF   THE    */
  29. /*    BINKLEYTERM  LICENSING AGREEMENT,  OR SUCH OTHER  AGREEMENT AS YOU    */
  30. /*    ARE ABLE TO REACH WITH THE AUTHORS.                                   */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /*    The Authors can be reached at the following addresses:                */
  34. /*                                                                          */
  35. /*    Robert C. Hartman                      Vincent E. Perriello           */
  36. /*    Spark Software                         VEP Software                   */
  37. /*    427-3 Amherst Street                   111 Carroll Street             */
  38. /*    CS2032, Suite 232                      Naugatuck, CT 06770            */
  39. /*    Nashua, NH 03061                                                      */
  40. /*                                                                          */
  41. /*    FidoNet 1:132/101                      FidoNet 1:141/491              */
  42. /*    Data    (603) 888-8179                 Data    (203) 729-7569         */
  43. /*                                                                          */
  44. /*    Please feel free to contact us at any time to share your comments     */
  45. /*    about our software and/or licensing policies.                         */
  46. /*                                                                          */
  47. /*--------------------------------------------------------------------------*/
  48. #include <string.h>
  49.  
  50. #include "com.h"
  51. #include "xfer.h"
  52. #include "zmodem.h"
  53. #include "keybd.h"
  54. #include "sbuf.h"
  55. #include "sched.h"
  56. #include "externs.h"
  57. #include "prototyp.h"
  58.  
  59.  
  60. /*--------------------------------------------------------------------------*/
  61. /*                                                                          */
  62. /* ansi_map() -- map function key into an ANSI escape sequence if we have   */
  63. /* one to correspond to the key. The "emulation" is VT100-type, we map the  */
  64. /* arrow keys to the ANSI escape sequences for up, down, right and left,    */
  65. /* and we map the function keys into the VT100 keypad, assuming application */
  66. /* mode, like Procomm. That is, we take the VT100 keypad, split it in two   */
  67. /* vertically, and use the F-keys to represent the left side, and the       */
  68. /* "shifted" F-keys to represent the right side.                            */
  69. /*                                                                          */
  70. /*              The result, if any, is transmitted to the host.             */
  71. /*                                                                          */
  72. /*--------------------------------------------------------------------------*/
  73. /* ESC Seq        IBM key       Scan code VT100 key    */
  74.  
  75. static char *ansi_seq[] = { 
  76.    "\033OP",   /* F1            3b00      PF1          */
  77.    "\033OQ",   /* F2            3c00      PF2          */
  78.    "\033Ow",   /* F3            3d00      keypad '7'   */
  79.    "\033Ox",   /* F4            3e00      keypad '8'   */
  80.    "\033Ot",   /* F5            3f00      keypad '4'   */
  81.    "\033Ou",   /* F6            4000      keypad '5'   */
  82.    "\033Oq",   /* F7            4100      keypad '1'   */
  83.    "\033Or",   /* F8            4200      keypad '2'   */
  84.    "\033Op",   /* F9            4300      keypad '0'   */
  85.    "\033Op",   /* F10           4400      keypad '0'   */
  86.    "",         /*               4500                   */
  87.    "",         /*               4600                   */
  88.    "",         /*               4700                   */
  89.    "\033[A",   /* Up Arrow      4800      Up Arrow     */
  90.    "",         /*               4900                   */
  91.    "",         /*               4a00                   */
  92.    "\033[D",   /* Left Arrow    4b00      Left Arrow   */
  93.    "",         /*               4c00                   */
  94.    "\033[C",   /* Right Arrow   4d00      Right Arrow  */
  95.    "",         /*               4e00                   */
  96.    "",         /*               4f00                   */
  97.    "\033[B",   /* Down Arrow    5000      Down Arrow   */
  98.    "",         /*               5100                   */
  99.    "",         /*               5200                   */
  100.    "",         /*               5300                   */
  101.    "\033OR",   /* Shift-F1      5400      PF3          */
  102.    "\033OS",   /* Shift-F2      5500      PF4          */
  103.    "\033Oy",   /* Shift-F3      5600      keypad '9'   */
  104.    "\033Om",   /* Shift-F4      5700      keypad '-'   */
  105.    "\033Ov",   /* Shift-F5      5800      keypad '6'   */
  106.    "\033Ol",   /* Shift-F6      5900      keypad ','   */
  107.    "\033Os",   /* Shift-F7      5a00      keypad '3'   */
  108.    "\033OM",   /* Shift-F8      5b00      keypad 'Enter' */
  109.    "\033On",   /* Shift-F9      5c00      keypad '.'   */
  110.    "\033OM",   /* Shift-F10     5d00      keypad 'Enter' */
  111.    ""
  112. };
  113.  
  114. void ansi_map (ScanVal)
  115. unsigned ScanVal;
  116. {
  117.    register KeyCode;
  118.    register char *s;
  119.  
  120.    KeyCode = ScanVal >> 8;                       /* Isolate to key scan code */
  121.    if ((KeyCode < 0x3b) || (KeyCode > 0x5d))
  122.       return;                                    /* Not in range, give up    */
  123.    s = ansi_seq[KeyCode - 0x3b];                 /* Index to our sequence    */
  124.    SENDCHARS (s, strlen (s), 0);                 /* Send the mapped string   */
  125. }
  126.